package com.bana.fvs.controller;

import com.bana.fvs.dao.StrategyDAO;
import com.bana.fvs.model.Strategy;
import com.bana.sys.code.DatabaseResult;
import com.bana.sys.utils.ActionResult;
import com.bana.sys.utils.TokenRequest;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/strategy", method = RequestMethod.POST)
public class StrategyController {

    @Resource
    private StrategyDAO strategyDAO;

    @RequestMapping(value = "/getStrategies.do", method = RequestMethod.POST)
    public List<Strategy> getStrategies(@RequestBody TokenRequest<Object> request)
    {
        return strategyDAO.getStrategies();
    }

    @RequestMapping(value = "/updateStrategy.do", method = RequestMethod.POST)
    public ActionResult updateStrategy(@RequestBody TokenRequest<Strategy> request)
    {
        ActionResult result=new ActionResult();
        strategyDAO.updateStrategy(request.getData());
        result.setCzjg(DatabaseResult.Success);
        return result;
    }
}
